package com.cj.user.service.huawei;

import java.util.*;
import java.util.stream.Collectors;

/**
 * @Author cheng jun
 * @Description:
 * @Date 2021/5/16 17:15
 */
public class ArrayContiguousSum {

    /**
     * 去重 + 排序
     * @param N
     * @param x
     * @return
     */
    public static List<Integer> arrayContiguousSum(Integer N, Integer x) {
        List<Integer> list = new ArrayList<>();
        for (int i = 0; i < N; i++) {
            list.add((int) (Math.random() * 100 + 1));
        }
        list.add(N);
        list.add(x);

        //存储去重排序后的集合
        List<Integer> list2 = list.stream().distinct().collect(Collectors.toList());
        Collections.sort(list2);
        list2.add(x);
        return list2;
    }

    /**
     * 计算符合要求的个数
     * @param list
     * @return
     */
    public static int moreThanTheX(List<Integer> list) {
        int standard = list.get(list.size() - 1);
        //去掉比对数
        list.remove(list.size() - 1);
        //计数
        int count = 0;
        for (int i = 0; i < list.size(); i++) {
            if (i + 1 < list.size()) {
                if (list.get(i) + list.get(i + 1) >= standard) {
                    count++;
                }
            }
        }
        return count;
    }

    public static void main(String[] args) {
        Scanner scanner = new Scanner(System.in);
        Scanner scanner2 = new Scanner(System.in);
        System.out.println(moreThanTheX(arrayContiguousSum(scanner.nextInt(), scanner2.nextInt())));
    }
}
